Skip to content

feat(live): custom org templates, Indonesian built-ins, safe domain removal - #24

Merged
dalpan merged 1 commit into
mainfrom
feature/templates-domain-delete
Nov 9, 2026
Merged

dalpan merged 1 commit into
mainfrom
feature/templates-domain-delete

Conversation

@dalpan

@dalpan dalpan commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Summary

Domain removal

  • DELETE /api/live/domains/{id} is now available to trainers and scoped to their organization. Before this change it was admin-only, but an admin could delete any organization's domain.
  • Removal returns 409 while an active campaign (pending_approval, approved, launching, running) or an active recurring schedule still sends from or to the domain or one of its subdomains. A running campaign keeps the verification it was approved under.
  • The UI adds a trash button on each domain with a two-click confirm (no browser dialog).

Custom templates (per organization)

  • POST /api/live/templates saves a custom template, and DELETE /api/live/templates/{id} removes one. Built-ins cannot be deleted (400).
  • GET returns the built-in templates plus the caller's organization templates. Admins see all.
  • A template must pass the same content checks as pre-flight (G7 objective/principles, G9 blocked themes, G10 agencies/brands, {{.URL}} for click_link). A saved template can therefore never be one that pre-flight blocks.

Built-in templates

  • seed_templates upserts built-ins by id. Previously it seeded only when the collection was empty, so new templates never reached existing instances.
  • Adds three Indonesian built-ins (password expiry, shared document, director payment request) and a language field on every template.

Campaign form

  • Templates are grouped as: your organization, built-in ID, built-in EN.
  • The EN/ID language selector is filled from the template, so AI persona replies use the same language.
  • Adds "save current content as template" and delete for custom templates.

Tests

  • 11 new tests in backend/tests/test_live.py cover:
    • built-ins passing the content guardrails
    • upsert seeding that leaves custom templates intact
    • organization scoping of custom templates
    • guardrail rejections (parametrized)
    • domain removal: cross-organization 404, 409 while used by a campaign or schedule, success once the campaign or schedule is inactive
  • Full suite: 271 passed. ruff check and ruff format --check are clean. CI=true npm run build passes.

🤖 Generated with Claude Code

…emoval

- Trainers can remove a verified domain in their own organization. Removal
  is refused (409) while an active campaign or recurring schedule still sends
  from or to that domain. Previously the endpoint was admin-only but not
  scoped, and nothing checked for active use.
- Custom phishing templates per organization: GET/POST/DELETE
  /api/live/templates. A saved template must pass the same content checks
  as pre-flight (G7, G9, G10, {{.URL}} for click_link). Built-ins cannot
  be deleted.
- seed_templates upserts built-ins by id, so templates added in a release
  reach instances seeded earlier. Adds three Indonesian built-ins and a
  language field on every template.
- Campaign form: templates grouped (organization / ID / EN), an EN/ID
  language selector filled from the template, save-as-template, delete for
  custom templates, and a two-click delete on domains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dalpan
dalpan merged commit db2cb0f into main Nov 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant